package edu.sctu.practice.class02.xuqianlan.assign.assign08.test3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * Created by hp on 2015/12/21.
 */
public class Server {
    public static void main(String[] args) {
        DatagramPacket pack=null;//打包
        DatagramSocket mailReceive=null;//网络编程
        ServerThread thread;
        byte b[]=new byte[8192];
        InetAddress address=null;
        pack =new DatagramPacket(b,b.length);
        while (true){
            try {
                mailReceive=new DatagramSocket(1234);
            }catch (IOException e1){
                System.out.println("正在等待");
            }
            try {
                mailReceive.receive(pack);
                address=pack.getAddress();
                System.out.println("客户的地址："+address);
            }catch (IOException e){}
            if (address!=null){
                new ServerThread(address).start();
            }else {
                continue;
            }
        }
    }
}
